package com.lst.selfaiagent.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Slf4j
@Api(tags = "AI接口")
public class OllamaAiController {

    private final OllamaChatModel chatModel;

    public OllamaAiController(OllamaChatModel chatModel) {
        this.chatModel = chatModel;
    }


    /**
     * 测试调用
     */
    @GetMapping("/ai/generate")
    @ApiOperation("生成AI内容")
    public Map<String,String> generate(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
        return Map.of("generation", this.chatModel.call(message));
    }


}